package vn.allmobile.newsreader.activities.main;

import java.util.List;

import vn.allmobile.newsreader.CategoriesActivity;
import vn.allmobile.newsreader.R;
import vn.allmobile.newsreader.activities.main.MainFlipViewAdapter;
import vn.allmobile.newsreader.adapters.HomeGridViewAdapter;
import vn.allmobile.newsreader.data.Paper;
import vn.allmobile.newsreader.utils.Contants;
import vn.allmobile.newsreader.utils.Log;
import vn.allmobile.newsreader.utils.Utils;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.Window;

import com.aphidmobile.flip.FlipViewController;

import com.jess.ui.TwoWayAdapterView;
//import com.jess.ui.TwoWayAdapterView;
import com.jess.ui.TwoWayAdapterView.OnItemClickListener;
import com.jess.ui.TwoWayGridView;

public class MainActivity extends Activity {
	List<Paper> mPapers;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_main);
		
		FlipViewController flipview = (FlipViewController)findViewById(R.id.flipViewMain);
		
		mPapers = Utils.getPapers(this);
		Log.v("mPaper size:" + mPapers.size());
		MainFlipViewAdapter adapter = new MainFlipViewAdapter(mPapers);
		flipview.setAdapter(adapter);
		/*TwoWayGridView mGrid = (TwoWayGridView) findViewById(R.id.gridview);
		
		mGrid.setAdapter(new HomeGridViewAdapter(this, mPapers));
		mGrid.setOnItemClickListener(onItemClick);
		*/
	}

	private OnItemClickListener onItemClick = new OnItemClickListener() {

		@Override
		public void onItemClick(TwoWayAdapterView<?> parent, View view,
				int position, long id) {
			Paper mCurrentPaper = mPapers.get(position);
			Contants.PAPER_PASS_TO_CATEGORYACTIVITY = mCurrentPaper;
			Intent mIntent = new Intent(getApplicationContext(),
					CategoriesActivity.class);
			startActivity(mIntent);
		}
	};

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
